package rensoft.android.presenter;

import rensoft.android.HasActivity;
import rensoft.android.HasActivityPresenter;

import android.os.Bundle;

public class StateTextViewPresenter extends HasActivityPresenter {

  private final int viewId;

  public StateTextViewPresenter(HasActivity hasActivity, int viewId) {
    super(hasActivity);
    this.viewId = viewId;
  }

  @Override
  public void onSaveInstanceState(Bundle state) {
    super.onSaveInstanceState(state);
    state.putString(viewId + "", getTextView(viewId).getText().toString());
  }

  @Override
  protected void onCreateRestore(Bundle state) {
    super.onCreateRestore(state);
    getTextView(viewId).setText(state.getString(viewId + ""));
  }

}
